    define(['angular'], function (angular) {
//    	console.log('主控制器controllers被加载！');
        var controllers = angular.module('app.controllers', []);
        controllers.controller('headerCtrl', ['$rootScope', '$scope', function($rootScope, $scope) {

        	if(typeof(EventSource)!=="undefined")
        	  {
        	  // Yes! Server-sent events support!
        		console.log('Yes! Server-sent events support!');
        	  // Some code.....
        	  }
        	else
        	  {
        	  // Sorry! No server-sent events support..
        		console.log('Sorry! No server-sent events support..');
        	  }
        	
			$scope.navActive=function(){
				//获取请求路径
				//获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
				$rootScope.curWwwPath=window.document.location.href;
				
				//获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
				$rootScope.pathName=window.document.location.pathname;
				$rootScope.pos=$scope.curWwwPath.indexOf($scope.pathName);
				//获取主机地址，如： http://localhost:8083
				$rootScope.localhostPaht=$scope.curWwwPath.substring(0,$scope.pos);
				//获取带"/"的项目名，如：/uimcardprj
				$rootScope.projectName=$scope.pathName.substring(0,$scope.pathName.substr(1).indexOf('/')+1);
			};
			
			$scope.navActive();
			
        	console.log('home主控制器headerCtrl运行完成!');
			
			}]);
        
        
    	//整个应用控制器
    	controllers.controller('appCtrl', [ '$rootScope', '$scope', '$location', appCtrl])
        
        function appCtrl($rootScope, $scope, $location) {
    		var Model = this;

    		$rootScope.topMyOgns = new Array();
    		$.get($rootScope.getServiceName() + '/backcenter/org/getMyOgnList', function(data){
    			$rootScope.topMyOgns = data;
    			console.log('$rootScope.topMyOgns-->',$rootScope.topMyOgns);
    			if($rootScope.topMyOgns.length>0){
    				$rootScope.topMyOgn = $rootScope.topMyOgns[0];
    			}
    			$scope.$apply();
    		});
    		
    		
    		//////////////////////////显示或者隐藏左侧菜单/////////////////////
    	    $scope.showLeftClick= function(){
    	    	$scope.showLeft = !$scope.showLeft;
    	    }
    	    
    	    if($(window).width()<768){
    	    	$scope.showLeft = false;
    		}else{
    	    	$scope.showLeft = true;
    	    }

    	    $scope.leftClick= function(){
//    	    	alert('');
    	    	if($(window).width()<768){
    		    	$scope.showLeft = false;
    			}
    	    }

    	    //////////////////////////////////////////////////////////////////


    		//全局函数
    		$rootScope.setCurrent = function(winid,winname,path) {
    			$rootScope.winid = winid;
    			$rootScope.winname = winname;
    			$rootScope.path = path;
    		}
    		
    	    //下面为路由监控事件
    	    //定义变量是为了关闭事件是调用
    	    var locationChangeStartOff = $rootScope.$on('$locationChangeStart', locationChangeStart);  
    	    var locationChangeSuccessOff = $rootScope.$on('$locationChangeSuccess', locationChangeSuccess);  

    	    function locationChangeStart(oldState,newState) { 
    	    	
    	    };
    	  
    	    function locationChangeSuccess(oldState,newState) {
    	    	//debugger;
    	        $rootScope.setCurrent($location.absUrl(),'',$location.path())
//    	    	console.log('oldState-->',oldState);
//    	    	console.log('newState-->',newState);
//    	    	console.log('$location.absUrl()-->',$location.absUrl());
//    	    	console.log('$location.path()-->',$location.path());
    	    };
    		
    	    
    		//页面渲染完成事件（指向ng-view）
    	    $scope.$on('$viewContentLoaded',function(){
//    	    	console.log('home.$viewContentLoaded-->',$location.path()+'页面渲染完成事件！');
    			$scope.$broadcast('ngViewLoaded',$location.path());
    	    });

    		//页面渲染完成事件（页面元素加载完成）
    	    $scope.bodyInit = function(){
//    	    	console.log('load!','页面渲染完成事件！');
//    			document.getElementById('loading').style.display = "none";
//    			document.getElementById('window').style.display = "";
//    			console.log('ng初始化完成！');
    	    };
    		
    		 $(document).ready(function(){ 
//    			console.log('$(document).ready！');
    		 });
    		 
			/*
			document.body.onkeyup=function(){
				alert('event-->',event);
				$scope.$broadcast('document_keyup',event);
			}
			*/
   	    
        	console.log('home主控制器appCtrl运行完成!');
    	    
    		return Model;

    	}
	
});